
package com.trydofor.a9task.base.code.sysd;

import com.trydofor.a9task.base.code.help.Code;
import com.trydofor.a9task.base.code.help.CodeBuilder;
import com.trydofor.a9task.base.sys.anno.SystemData;

/**
 * @author : Shi Rongjiu (www.trydofor.com)
 * @date : 2012-12-23
 * @see :
 */

public abstract class PassHard {

    public final static int    $   = GroupRoot.$PASS_HARD$;
    public final static String _   = "PASS_HARD$";
    @SystemData
    public final static Code   $_  = CodeBuilder.code(GroupRoot.$, $, _)
   	                                            .lang(Language.$EN_US, "password shield", "how hard to crack")
   	                                            .lang(Language.$ZH_CN, "密码强度", "密码被破解的难度")
                                                .done();
    
    public final static int    $WEAK  = $ + 1;
    public final static String _WEAK  = "PASS_HARD$WEAK";
    @SystemData
    public final static Code   WEAK   = CodeBuilder.code($, $WEAK, _WEAK)
   	                                               .lang(Language.$EN_US, "weak", "easy to guess")
   	                                               .lang(Language.$ZH_CN, "脆弱", "容易猜到")
                                                   .done();
    public final static int    $SOFT  = $ + 2;
    public final static String _SOFT  = "PASS_HARD$SOFT";
    @SystemData
    public final static Code   SOFT   = CodeBuilder.code($, $SOFT, _SOFT)
   	                                               .lang(Language.$EN_US, "soft", "easy to crack")
   	                                               .lang(Language.$ZH_CN, "一般", "容易破解")
                                                   .done();
    public final static int    $GOOD  = $ + 3;
    public final static String _GOOD  = "PASS_HARD$GOOD";
    @SystemData
    public final static Code   GOOD   = CodeBuilder.code($, $GOOD, _GOOD)
   	                                               .lang(Language.$EN_US, "good", "hard to crack")
   	                                               .lang(Language.$ZH_CN, "很好", "不易破解")
                                                   .done();
    public final static int    $BEST  = $ + 4;
    public final static String _BEST  = "PASS_HARD$BEST";
    @SystemData
    public final static Code   BEST   = CodeBuilder.code($, $BEST, _BEST)
   	                                               .lang(Language.$EN_US, "best", "too hard to crack")
   	                                               .lang(Language.$ZH_CN, "最好", "太难破解")
                                                   .done();

    ///////////////////////
    /**
     * true if id is the system default data
     * @param id the code id
     * @return
     */
    public final static boolean in(int id){
        if($WEAK == id) return true;
        if($SOFT == id) return true;
        if($GOOD == id) return true;
        if($BEST == id) return true;
        return false;
    }
    
    /**
     * get the code by id
     * @param id the code id
     * @return
     */
    public final static Code of(int id){
        if($WEAK == id) return WEAK;
        if($SOFT == id) return SOFT;
        if($GOOD == id) return GOOD;
        if($BEST == id) return BEST;
        return null;
    }
    
    /**
     * get the code by key
     * @param id the code key
     * @return
     */
    public final static Code of(String key){
        if(key == null) return null;
        if(_WEAK.equals(key)) return WEAK;
        if(_SOFT.equals(key)) return SOFT;
        if(_GOOD.equals(key)) return GOOD;
        if(_BEST.equals(key)) return BEST;
        return null;
    }
}
